home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 2 code / Secret Life of Mem. Mgr. / HeapDemo.r < prev    next >
Encoding:
Text File  |  1990-01-31  |  12.7 KB  |  789 lines  |  [TEXT/MPS ]

  1. #include    "Types.r"
  2. #include    "SysTypes.r"
  3.  
  4. resource 'WIND' (1000, "Legend", purgeable) {
  5.     {40, 40, 144, 222},
  6.     noGrowDocProc,
  7.     invisible,
  8.     goAway,
  9.     0x0,
  10.     "Legend"
  11. };
  12.  
  13. resource 'WIND' (2000, "About", purgeable) {
  14.     {42, 12, 210, 402},
  15.     zoomDocProc,
  16.     invisible,
  17.     goAway,
  18.     0x0,
  19.     "About HeapDemo"
  20. };
  21.  
  22. resource 'MENU' (1000, "Apple") {
  23.     1000,
  24.     textMenuProc,
  25.     0x7FFFFFFD,
  26.     enabled,
  27.     apple,
  28.     {    /* array: 2 elements */
  29.         /* [1] */
  30.         "About HeapDemo…", noIcon, noKey, noMark, plain,
  31.         /* [2] */
  32.         "-", noIcon, noKey, noMark, plain
  33.     }
  34. };
  35.  
  36. resource 'MENU' (1001, "File") {
  37.     1001,
  38.     textMenuProc,
  39.     0x7FFFFFFB,
  40.     enabled,
  41.     "File",
  42.     {    /* array: 4 elements */
  43.         /* [1] */
  44.         "Open Display", noIcon, "O", noMark, plain,
  45.         /* [2] */
  46.         "Close", noIcon, "W", noMark, plain,
  47.         /* [3] */
  48.         "-", noIcon, noKey, noMark, plain,
  49.         /* [4] */
  50.         "Quit", noIcon, "Q", noMark, plain
  51.     }
  52. };
  53.  
  54. resource 'MENU' (1002, "Edit", preload) {
  55.     1002,
  56.     textMenuProc,
  57.     0x7FFFFFFD,
  58.     disabled,
  59.     "Edit",
  60.     {    /* array: 6 elements */
  61.         /* [1] */
  62.         "Undo", noIcon, "Z", noMark, plain,
  63.         /* [2] */
  64.         "-", noIcon, noKey, noMark, plain,
  65.         /* [3] */
  66.         "Cut", noIcon, "X", noMark, plain,
  67.         /* [4] */
  68.         "Copy", noIcon, "C", noMark, plain,
  69.         /* [5] */
  70.         "Paste", noIcon, "V", noMark, plain,
  71.         /* [6] */
  72.         "Clear", noIcon, noKey, noMark, plain
  73.     }
  74. };
  75.  
  76. resource 'MENU' (1003, "Window", preload) {
  77.     1003,
  78.     textMenuProc,
  79.     0x7FFFFFFB,
  80.     enabled,
  81.     "Window",
  82.     {    /* array: 4 elements */
  83.         /* [1] */
  84.         "Novice Display", noIcon, noKey, check, plain,
  85.         /* [2] */
  86.         "Advanced Display", noIcon, noKey, noMark, plain,
  87.         /* [3] */
  88.         "-", noIcon, noKey, noMark, plain,
  89.         /* [4] */
  90.         "Show Legend", noIcon, noKey, noMark, plain
  91.     }
  92. };
  93.  
  94. resource 'MENU' (1004, "Special", preload) {
  95.     1004,
  96.     textMenuProc,
  97.     allEnabled,
  98.     enabled,
  99.     "Special",
  100.     {    /* array: 1 elements */
  101.         /* [1] */
  102.         "Delete all blocks", noIcon, noKey, noMark, plain
  103.     }
  104. };
  105.  
  106. resource 'DLOG' (1000, "About", purgeable) {
  107.     {60, 102, 262, 416},
  108.     dBoxProc,
  109.     visible,
  110.     goAway,
  111.     0x0,
  112.     1000,
  113.     "About HeapDemo"
  114. };
  115.  
  116. resource 'DLOG' (1002, "Extended Memory Display", purgeable, preload) {
  117.     {40, 4, 336, 508},
  118.     noGrowDocProc,
  119.     invisible,
  120.     goAway,
  121.     0x0,
  122.     1002,
  123.     "Heap Display"
  124. };
  125.  
  126. resource 'DLOG' (1001, "Memory Display", purgeable, preload) {
  127.     {40, 4, 336, 508},
  128.     noGrowDocProc,
  129.     invisible,
  130.     goAway,
  131.     0x0,
  132.     1001,
  133.     "Heap Display"
  134. };
  135.  
  136. resource 'DITL' (1000, "About", purgeable) {
  137.     {    /* array DITLarray: 2 elements */
  138.         /* [1] */
  139.         {157, 229, 189, 305},
  140.         Button {
  141.             enabled,
  142.             "OK"
  143.         },
  144.         /* [2] */
  145.         {7, 9, 188, 216},
  146.         StaticText {
  147.             disabled,
  148.             "HeapDemo v 1.3.2\n  Written by:\n    Richa"
  149.             "rd Clark\n\n  Useful suggestions by:\n    J"
  150.             "ames Sulzen, Dave Feldt,\n    Eric Shapir"
  151.             "o\n\n    \n©1989 by Apple Computer Inc. \nAl"
  152.             "l rights reserved.\n"
  153.         }
  154.     }
  155. };
  156.  
  157. resource 'DITL' (1002, "Extended Memory Display", purgeable) {
  158.     {    /* array DITLarray: 31 elements */
  159.         /* [1] */
  160.         {32, 8, 288, 112},
  161.         UserItem {
  162.             enabled
  163.         },
  164.         /* [2] */
  165.         {32, 120, 288, 224},
  166.         UserItem {
  167.             enabled
  168.         },
  169.         /* [3] */
  170.         {8, 232, 29, 329},
  171.         Button {
  172.             enabled,
  173.             "NewHandle"
  174.         },
  175.         /* [4] */
  176.         {32, 232, 53, 329},
  177.         Button {
  178.             enabled,
  179.             "HLock"
  180.         },
  181.         /* [5] */
  182.         {56, 232, 77, 329},
  183.         Button {
  184.             enabled,
  185.             "HUnlock"
  186.         },
  187.         /* [6] */
  188.         {128, 232, 149, 329},
  189.         Button {
  190.             enabled,
  191.             "MoveHHi"
  192.         },
  193.         /* [7] */
  194.         {152, 232, 173, 329},
  195.         Button {
  196.             enabled,
  197.             "DisposHandle"
  198.         },
  199.         /* [8] */
  200.         {184, 232, 205, 329},
  201.         Button {
  202.             enabled,
  203.             "NewPtr"
  204.         },
  205.         /* [9] */
  206.         {208, 232, 229, 329},
  207.         Button {
  208.             enabled,
  209.             "DisposPtr"
  210.         },
  211.         /* [10] */
  212.         {11, 334, 27, 358},
  213.         EditText {
  214.             enabled,
  215.             "1"
  216.         },
  217.         /* [11] */
  218.         {187, 336, 203, 360},
  219.         EditText {
  220.             enabled,
  221.             "1"
  222.         },
  223.         /* [12] */
  224.         {8, 138, 24, 209},
  225.         StaticText {
  226.             disabled,
  227.             "Present…"
  228.         },
  229.         /* [13] */
  230.         {8, 32, 24, 96},
  231.         StaticText {
  232.             disabled,
  233.             "Past…"
  234.         },
  235.         /* [14] */
  236.         {11, 365, 31, 385},
  237.         StaticText {
  238.             disabled,
  239.             "K"
  240.         },
  241.         /* [15] */
  242.         {187, 368, 207, 388},
  243.         StaticText {
  244.             disabled,
  245.             "K"
  246.         },
  247.         /* [16] */
  248.         {176, 232, 181, 413},
  249.         Picture {
  250.             disabled,
  251.             1000
  252.         },
  253.         /* [17] */
  254.         {232, 232, 248, 328},
  255.         StaticText {
  256.             disabled,
  257.             "Total free:"
  258.         },
  259.         /* [18] */
  260.         {232, 336, 248, 504},
  261.         StaticText {
  262.             disabled,
  263.             "16536 bytes (16K)"
  264.         },
  265.         /* [19] */
  266.         {256, 232, 272, 328},
  267.         StaticText {
  268.             disabled,
  269.             "After purge:"
  270.         },
  271.         /* [20] */
  272.         {256, 336, 272, 504},
  273.         StaticText {
  274.             disabled,
  275.             "16536 bytes (16K)"
  276.         },
  277.         /* [21] */
  278.         {280, 232, 297, 283},
  279.         StaticText {
  280.             disabled,
  281.             "Result:"
  282.         },
  283.         /* [22] */
  284.         {280, 336, 296, 504},
  285.         StaticText {
  286.             disabled,
  287.             "noErr"
  288.         },
  289.         /* [23] */
  290.         {80, 232, 101, 329},
  291.         Button {
  292.             enabled,
  293.             "HPurge"
  294.         },
  295.         /* [24] */
  296.         {104, 232, 125, 329},
  297.         Button {
  298.             enabled,
  299.             "HNoPurge"
  300.         },
  301.         /* [25] */
  302.         {56, 344, 77, 441},
  303.         Button {
  304.             enabled,
  305.             "MaxMem"
  306.         },
  307.         /* [26] */
  308.         {80, 344, 101, 441},
  309.         Button {
  310.             enabled,
  311.             "CompactMem"
  312.         },
  313.         /* [27] */
  314.         {104, 344, 125, 441},
  315.         Button {
  316.             enabled,
  317.             "PurgeMem"
  318.         },
  319.         /* [28] */
  320.         {83, 448, 99, 472},
  321.         EditText {
  322.             enabled,
  323.             "1"
  324.         },
  325.         /* [29] */
  326.         {108, 448, 124, 472},
  327.         EditText {
  328.             enabled,
  329.             "1"
  330.         },
  331.         /* [30] */
  332.         {80, 480, 100, 500},
  333.         StaticText {
  334.             disabled,
  335.             "K"
  336.         },
  337.         /* [31] */
  338.         {104, 480, 124, 500},
  339.         StaticText {
  340.             disabled,
  341.             "K"
  342.         }
  343.     }
  344. };
  345.  
  346. resource 'DITL' (2000, "Look, no touch", purgeable) {
  347.     {    /* array DITLarray: 2 elements */
  348.         /* [1] */
  349.         {53, 181, 73, 241},
  350.         Button {
  351.             enabled,
  352.             "OK"
  353.         },
  354.         /* [2] */
  355.         {7, 58, 45, 241},
  356.         StaticText {
  357.             disabled,
  358.             "You can look at the old heap, but not to"
  359.             "uch."
  360.         }
  361.     }
  362. };
  363.  
  364. resource 'DITL' (2001, "Bad request", purgeable) {
  365.     {    /* array DITLarray: 2 elements */
  366.         /* [1] */
  367.         {53, 181, 73, 241},
  368.         Button {
  369.             enabled,
  370.             "OK"
  371.         },
  372.         /* [2] */
  373.         {7, 58, 45, 241},
  374.         StaticText {
  375.             disabled,
  376.             "Please enter an integer between 1 and ^0"
  377.         }
  378.     }
  379. };
  380.  
  381. resource 'DITL' (2002, "No Demo Memory", purgeable) {
  382.     {    /* array DITLarray: 2 elements */
  383.         /* [1] */
  384.         {53, 181, 73, 241},
  385.         Button {
  386.             enabled,
  387.             "OK"
  388.         },
  389.         /* [2] */
  390.         {7, 58, 45, 241},
  391.         StaticText {
  392.             disabled,
  393.             "There's not enough room to allocate anot"
  394.             "her block."
  395.         }
  396.     }
  397. };
  398.  
  399. resource 'DITL' (2003, "No More Blocks", purgeable) {
  400.     {    /* array DITLarray: 2 elements */
  401.         /* [1] */
  402.         {53, 181, 73, 241},
  403.         Button {
  404.             enabled,
  405.             "OK"
  406.         },
  407.         /* [2] */
  408.         {7, 58, 45, 241},
  409.         StaticText {
  410.             disabled,
  411.             "Sorry, only ^0 blocks are allowed in thi"
  412.             "s demo."
  413.         }
  414.     }
  415. };
  416.  
  417. resource 'DITL' (1001, "Memory Display", purgeable) {
  418.     {    /* array DITLarray: 22 elements */
  419.         /* [1] */
  420.         {32, 16, 272, 128},
  421.         UserItem {
  422.             enabled
  423.         },
  424.         /* [2] */
  425.         {32, 144, 272, 256},
  426.         UserItem {
  427.             enabled
  428.         },
  429.         /* [3] */
  430.         {8, 280, 29, 377},
  431.         Button {
  432.             enabled,
  433.             "NewHandle"
  434.         },
  435.         /* [4] */
  436.         {32, 280, 53, 377},
  437.         Button {
  438.             enabled,
  439.             "HLock"
  440.         },
  441.         /* [5] */
  442.         {56, 280, 77, 377},
  443.         Button {
  444.             enabled,
  445.             "HUnlock"
  446.         },
  447.         /* [6] */
  448.         {80, 280, 101, 377},
  449.         Button {
  450.             enabled,
  451.             "MoveHHi"
  452.         },
  453.         /* [7] */
  454.         {104, 280, 125, 377},
  455.         Button {
  456.             enabled,
  457.             "DisposHandle"
  458.         },
  459.         /* [8] */
  460.         {152, 280, 173, 377},
  461.         Button {
  462.             enabled,
  463.             "NewPtr"
  464.         },
  465.         /* [9] */
  466.         {176, 280, 197, 377},
  467.         Button {
  468.             enabled,
  469.             "DisposPtr"
  470.         },
  471.         /* [10] */
  472.         {11, 384, 27, 408},
  473.         EditText {
  474.             enabled,
  475.             "1"
  476.         },
  477.         /* [11] */
  478.         {155, 384, 171, 408},
  479.         EditText {
  480.             enabled,
  481.             "1"
  482.         },
  483.         /* [12] */
  484.         {8, 162, 25, 235},
  485.         StaticText {
  486.             disabled,
  487.             "Present…"
  488.         },
  489.         /* [13] */
  490.         {8, 40, 24, 104},
  491.         StaticText {
  492.             disabled,
  493.             "Past…"
  494.         },
  495.         /* [14] */
  496.         {11, 416, 31, 436},
  497.         StaticText {
  498.             disabled,
  499.             "K"
  500.         },
  501.         /* [15] */
  502.         {155, 416, 175, 436},
  503.         StaticText {
  504.             disabled,
  505.             "K"
  506.         },
  507.         /* [16] */
  508.         {136, 280, 139, 461},
  509.         Picture {
  510.             disabled,
  511.             1000
  512.         },
  513.         /* [17] */
  514.         {216, 264, 232, 360},
  515.         StaticText {
  516.             disabled,
  517.             "Free memory:"
  518.         },
  519.         /* [18] */
  520.         {216, 368, 232, 504},
  521.         StaticText {
  522.             disabled,
  523.             "16536 bytes (16K)"
  524.         },
  525.         /* [19] */
  526.         {0, 1264, 16, 1360},
  527.         StaticText {
  528.             disabled,
  529.             "After purge:"
  530.         },
  531.         /* [20] */
  532.         {0, 1368, 16, 1504},
  533.         StaticText {
  534.             disabled,
  535.             "16536 bytes (16K)"
  536.         },
  537.         /* [21] */
  538.         {264, 264, 281, 315},
  539.         StaticText {
  540.             disabled,
  541.             "Result:"
  542.         },
  543.         /* [22] */
  544.         {264, 368, 280, 504},
  545.         StaticText {
  546.             disabled,
  547.             "noErr"
  548.         }
  549.     }
  550. };
  551.  
  552. resource 'DITL' (2004, "No More Blocks", purgeable) {
  553.     {    /* array DITLarray: 3 elements */
  554.         /* [1] */
  555.         {71, 59, 91, 119},
  556.         Button {
  557.             enabled,
  558.             "OK"
  559.         },
  560.         /* [2] */
  561.         {72, 214, 92, 274},
  562.         Button {
  563.             enabled,
  564.             "Cancel"
  565.         },
  566.         /* [3] */
  567.         {7, 59, 62, 274},
  568.         StaticText {
  569.             disabled,
  570.             "Do you really want to delete all blocks "
  571.             "in the heap?"
  572.         }
  573.     }
  574. };
  575.  
  576. resource 'ALRT' (1000, "NoOldHeap") {
  577.     {66, 34, 148, 288},
  578.     2000,
  579.     {    /* array: 4 elements */
  580.         /* [1] */
  581.         OK, visible, sound1,
  582.         /* [2] */
  583.         OK, visible, sound1,
  584.         /* [3] */
  585.         OK, visible, sound1,
  586.         /* [4] */
  587.         OK, visible, sound1
  588.     }
  589. };
  590.  
  591. resource 'ALRT' (1001, "Wrong Size") {
  592.     {66, 34, 148, 288},
  593.     2001,
  594.     {    /* array: 4 elements */
  595.         /* [1] */
  596.         OK, visible, sound1,
  597.         /* [2] */
  598.         OK, visible, sound1,
  599.         /* [3] */
  600.         OK, visible, sound1,
  601.         /* [4] */
  602.         OK, visible, sound1
  603.     }
  604. };
  605.  
  606. resource 'ALRT' (1002, "No Demo Mem") {
  607.     {66, 34, 148, 288},
  608.     2002,
  609.     {    /* array: 4 elements */
  610.         /* [1] */
  611.         OK, visible, sound1,
  612.         /* [2] */
  613.         OK, visible, sound1,
  614.         /* [3] */
  615.         OK, visible, sound1,
  616.         /* [4] */
  617.         OK, visible, sound1
  618.     }
  619. };
  620.  
  621. resource 'ALRT' (1003, "No More Blocks") {
  622.     {66, 34, 148, 288},
  623.     2003,
  624.     {    /* array: 4 elements */
  625.         /* [1] */
  626.         OK, visible, sound1,
  627.         /* [2] */
  628.         OK, visible, sound1,
  629.         /* [3] */
  630.         OK, visible, sound1,
  631.         /* [4] */
  632.         OK, visible, sound1
  633.     }
  634. };
  635.  
  636. resource 'ALRT' (1004, "Special feature") {
  637.     {64, 34, 164, 326},
  638.     2004,
  639.     {    /* array: 4 elements */
  640.         /* [1] */
  641.         OK, visible, sound1,
  642.         /* [2] */
  643.         OK, visible, sound1,
  644.         /* [3] */
  645.         OK, visible, sound1,
  646.         /* [4] */
  647.         OK, visible, sound1
  648.     }
  649. };
  650.  
  651. resource 'PICT' (1000, purgeable) {
  652.     47,
  653.     {0, 0, 3, 181},
  654.     $"1101 0E00 0001 9901 000A 0000 0000 0018"
  655.     $"00B6 09AA 55AA 55AA 55AA 5520 0001 0001"
  656.     $"0001 00A2 FF"
  657. };
  658.  
  659. resource 'PICT' (1001, "Legend Picture") {
  660.     191,
  661.     {0, 0, 96, 181},
  662.     $"1101 0100 0A00 0000 0000 7500 B603 0003"
  663.     $"0441 0D00 0C2B 4212 064C 6567 656E 640E"
  664.     $"0000 0199 0700 0200 0220 0018 000A 0018"
  665.     $"00AB 0E00 0001 550A 8800 2200 8800 2200"
  666.     $"3400 1E00 0F00 3800 5007 0001 0001 380E"
  667.     $"0000 0021 0401 0D00 0928 0034 0011 0B6E"
  668.     $"6E20 5B4C 6F63 6B65 645D 0D00 0C28 002F"
  669.     $"0055 0B52 656C 6F63 6174 6162 6C65 0E00"
  670.     $"0000 CD0A 0102 0408 1020 4080 3400 3C00"
  671.     $"0F00 5600 5038 0E00 0000 210D 0009 2800"
  672.     $"5300 1102 6E6E 0D00 0C28 004E 0055 0546"
  673.     $"6978 6564 FF"
  674. };
  675.  
  676. data 'hpdm' (0) {
  677.     $"4348 6561 7044 656D 6F20 312E 332E 332C"            /* CHeapDemo 1.3.3, */
  678.     $"20A9 2031 3938 3920 6279 2041 7070 6C65"            /*  © 1989 by Apple */
  679.     $"2043 6F6D 7075 7465 722C 2049 6E63 2E20"            /*  Computer, Inc.  */
  680.     $"416C 6C20 7269 6768 7473 2072 6573 6572"            /* All rights reser */
  681.     $"7665 642E"                                          /* ved. */
  682. };
  683.  
  684. resource 'BNDL' (128) {
  685.     'hpdm',
  686.     0,
  687.     {    /* array TypeArray: 2 elements */
  688.         /* [1] */
  689.         'FREF',
  690.         {    /* array IDArray: 1 elements */
  691.             /* [1] */
  692.             0, 128
  693.         },
  694.         /* [2] */
  695.         'ICN#',
  696.         {    /* array IDArray: 1 elements */
  697.             /* [1] */
  698.             0, 128
  699.         }
  700.     }
  701. };
  702.  
  703. resource 'FREF' (128) {
  704.     'APPL',
  705.     0,
  706.     ""
  707. };
  708.  
  709. resource 'ICN#' (128) {
  710.     {    /* array: 2 elements */
  711.         /* [1] */
  712.         $"07FF E000 06AA A000 0555 6000 06AA A000"
  713.         $"07FF E000 0400 2000 0400 2000 07FF E000"
  714.         $"0524 F800 064B 2C00 0495 FA00 052E 3B00"
  715.         $"07F8 6F80 0418 C280 0419 8780 041B 0D80"
  716.         $"041E 1980 041F FF80 041F FF00 040C 0280"
  717.         $"040B 0E40 040E FD20 0407 FE90 0401 F348"
  718.         $"0400 21A8 0400 20FC 0400 203C 07FF E01C"
  719.         $"0524 A008 0649 2000 0492 2000 07FF E0",
  720.         /* [2] */
  721.         $"07FF E000 07FF E000 07FF E000 07FF E000"
  722.         $"07FF E000 07FF E000 07FF E000 07FF E000"
  723.         $"07FF F800 07FF FC00 07FF FE00 07FF FF00"
  724.         $"07FF FF80 07FF FF80 07FF FF80 07FF FF80"
  725.         $"07FF FF80 07FF FF80 07FF FF00 07FF FF80"
  726.         $"07FF FFC0 07FF FFE0 07FF FFF0 07FF F3F8"
  727.         $"07FF E1F8 07FF E0FC 07FF E03C 07FF E01C"
  728.         $"07FF E008 07FF E000 07FF E000 07FF E0"
  729.     }
  730. };
  731.  
  732. resource 'vers' (1) {
  733.     0x1,
  734.     0x33,
  735.     0x0,
  736.     0x0,
  737.     verUs,
  738.     "1.3.3",
  739.     "1.3.3 ©1989 by Apple Computer, Inc. All "
  740.     "Rights Reserved."
  741. };
  742.  
  743. resource 'SIZE' (-1) {
  744.     dontSaveScreen,
  745.     ignoreSuspendResumeEvents,
  746.     enableOptionSwitch,
  747.     cannotBackground,
  748.     notMultiFinderAware,
  749.     backgroundAndForeground,
  750.     dontGetFrontClicks,
  751.     ignoreChildDiedEvents,
  752.     not32BitCompatible,
  753.     reserved,
  754.     reserved,
  755.     reserved,
  756.     reserved,
  757.     reserved,
  758.     reserved,
  759.     reserved,
  760.     1024 * 120,
  761.     1024 * 120
  762. };
  763.  
  764. resource 'STR#' (1000, "Block states", purgeable) {
  765.     {    /* array StringArray: 2 elements */
  766.         /* [1] */
  767.         " Lock",
  768.         /* [2] */
  769.         " Purge"
  770.     }
  771. };
  772.  
  773. resource 'STR#' (1001, "Status messages", purgeable) {
  774.     {    /* array StringArray: 2 elements */
  775.         /* [1] */
  776.         "There's not enough room to allocate anot"
  777.         "her block.",
  778.         /* [2] */
  779.         "PurgeMem couldn't get the requested amou"
  780.         "nt."
  781.     }
  782. };
  783.  
  784. data 'pref' (1000, purgeable) {
  785.     $"0000"                                               /* .. */
  786. };
  787.  
  788. INCLUDE "About Box Text and Style";
  789.